home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1997
/
MacHack 1997.toast
/
Hacks
/
Hacks ’96
/
Vowel Doubler
/
Vowel Doubler.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-06-22
|
2KB
|
69 lines
/****************************************
* Vowel Doubler - © 1996 Shane D. Looker All Rights Reserved
*
* This is a quick hack based on my PatchMaster source. It is compiled
* under Think Project Manager 7.0.4. It is a fusion of NVls (No Vowels)
* with a simple PPostEvent.
*
*****************************************/
typedef struct {
Boolean isAlive;
} MyGlobal, *MyGlobalP;
pascal void main(void);
pascal void main(void)
{
Ptr addr;
Ptr globalP;
long rD0;
EventRecord *rA1;
asm {
MOVEM.L A2-A5/D1-D7, -(A7) /* Save the non-volitle registers */
MOVE.L d0, rD0 /* Get to d0 & a0 easily */
MOVE.L a1, rA1
}
addr = *(Ptr *)(((Ptr)&main) - 8); /* Get the address of last filter */
globalP = *(Ptr *)(((Ptr)&main) - 4); /* Get the address of global storage */
/* The structure is:
long last filter address;
Ptr globalDataSpace; */
if ((rA1->what == keyDown) || (rA1->what == autoKey))
{
char theChar = rA1->message & charCodeMask;
if ((theChar == 'a') || (theChar == 'e') || (theChar == 'i') || (theChar == 'o') || (theChar == 'u')
|| (theChar == 'A') || (theChar == 'E') || (theChar == 'I') || (theChar == 'O') || (theChar == 'U'))
{
short err;
EvQElPtr qP;
if (((MyGlobalP)globalP)->isAlive == false)
{
err = PPostEvent(keyDown, /*(0x09 << 8) |*/ theChar, &qP); /* YAMN - Yet Another Magic Number */
if (!err)
{
qP->evtQWhen = TickCount();
qP->evtQModifiers = 0;
((MyGlobalP)globalP)->isAlive = true;
}
}
else
((MyGlobalP)globalP)->isAlive = false;
}
}
asm {
MOVEM.L (A7)+, A2-A5/D1-D7 /* Restore the non-volitle registers */
MOVE.L rD0, d0
MOVE.L rA1, a1
MOVE.L addr, A0
UNLK A6
JMP (A0)
};
}